{% extends 'app_admin/admin_base.html' %}
{% load static %}
{% load i18n %}
{% block title %}仪表盘{% endblock %}

{% block custom_element %}
    <link rel="stylesheet" href="{% static 'PearAdminLayui/admin/css/other/console1.css' %}" />
{% endblock %}

{% block content %}
<div>
    <div class="layui-row layui-col-space10">
        <div class="layui-col-xs6 layui-col-md8 layui-col-space5">
            <div class="layui-col-xs6 layui-col-md3">
                <div class="layui-card top-panel">
                    <div class="layui-card-header">用户总数</div>
                    <div class="layui-card-body">
                        <div class="layui-row layui-col-space5">
                            <div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;" id="pro_cnt">
                                {{ user_cnt }}
                            </div>
                            <div class="layui-col-xs4 layui-col-md4 top-panel-tips">
                                <svg t="1606220167131" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2438" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><defs><style type="text/css"></style></defs><path d="M512 929.959184c-230.4 0-417.959184-187.559184-417.959184-417.959184s187.559184-417.959184 417.959184-417.959184 417.959184 187.559184 417.959184 417.959184-187.559184 417.959184-417.959184 417.959184z" fill="#16C4AF" p-id="2439"></path><path d="M512 715.755102c-46.497959 0-90.383673-6.269388-123.297959-17.240816-55.379592-18.808163-67.395918-47.020408-67.395919-67.918368 0-71.57551 46.497959-135.836735 119.118368-162.481632 7.836735-3.134694 16.718367-1.044898 22.465306 5.22449 13.061224 14.106122 30.82449 21.942857 49.110204 21.942857s35.526531-7.836735 49.110204-21.942857c5.746939-6.269388 14.628571-8.359184 22.465306-5.22449 72.097959 27.167347 119.118367 90.906122 119.118368 162.481632-0.522449 62.693878-102.922449 85.159184-190.693878 85.159184z" fill="#0B9682" p-id="2440"></path><path d="M512 532.897959c-62.171429 0-112.326531-50.677551-112.326531-112.32653S449.828571 308.244898 512 308.244898s112.326531 50.677551 112.326531 112.326531S574.171429 532.897959 512 532.897959z" fill="#DCFFFA" p-id="2441"></path></svg>                        </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-md3">
                <div class="layui-card top-panel">
                    <div class="layui-card-header">文集总数</div>
                    <div class="layui-card-body">
                        <div class="layui-row layui-col-space5">
                            <div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;" id="pro_cnt">
                                {{ pro_cnt }}
                            </div>
                            <div class="layui-col-xs4 layui-col-md4 top-panel-tips">
                                <svg t="1606220627766" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2169" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><defs><style type="text/css"></style></defs><path d="M884.506122 271.673469H505.208163c-13.583673 0-24.555102-9.404082-24.555102-20.897959s10.971429-20.897959 24.555102-20.897959h379.297959c13.583673 0 24.555102 9.404082 24.555102 20.897959s-10.971429 20.897959-24.555102 20.897959zM884.506122 438.857143H505.208163c-13.583673 0-24.555102-9.404082-24.555102-20.897959s10.971429-20.897959 24.555102-20.89796h379.297959c13.583673 0 24.555102 9.404082 24.555102 20.89796s-10.971429 20.897959-24.555102 20.897959zM359.444898 491.102041H183.902041C145.763265 491.102041 114.938776 460.277551 114.938776 422.138776V246.595918C114.938776 208.457143 145.763265 177.632653 183.902041 177.632653h176.065306C397.583673 177.632653 428.408163 208.457143 428.408163 246.595918v176.065306C428.408163 460.277551 397.583673 491.102041 359.444898 491.102041zM884.506122 626.938776H505.208163c-13.583673 0-24.555102-9.404082-24.555102-20.89796s10.971429-20.897959 24.555102-20.897959h379.297959c13.583673 0 24.555102 9.404082 24.555102 20.897959s-10.971429 20.897959-24.555102 20.89796zM884.506122 794.122449H505.208163c-13.583673 0-24.555102-9.404082-24.555102-20.897959s10.971429-20.897959 24.555102-20.897959h379.297959c13.583673 0 24.555102 9.404082 24.555102 20.897959s-10.971429 20.897959-24.555102 20.897959z" fill="#16C4AF" p-id="2170"></path><path d="M359.444898 846.367347H183.902041c-38.138776 0-68.963265-30.82449-68.963265-68.963265v-176.065306c0-38.138776 30.82449-68.963265 68.963265-68.963266h176.065306c38.138776 0 68.963265 30.82449 68.963265 68.963266v176.065306c-0.522449 38.138776-31.346939 68.963265-69.485714 68.963265z" fill="#16C4AF" p-id="2171"></path></svg>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-md3">
                <div class="layui-card top-panel">
                    <div class="layui-card-header">文档总数</div>
                    <div class="layui-card-body">
                        <div class="layui-row layui-col-space5">
                            <div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;" id="doc_cnt">
                                {{ doc_cnt }}
                            </div>
                            <div class="layui-col-xs4 layui-col-md4 top-panel-tips">
                                <svg t="1606220673973" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2315" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><defs><style type="text/css"></style></defs><path d="M736.653061 929.959184H287.346939c-45.97551 0-83.591837-37.616327-83.591837-83.591837V177.632653c0-45.97551 37.616327-83.591837 83.591837-83.591837h449.306122c45.97551 0 83.591837 37.616327 83.591837 83.591837v668.734694c0 45.97551-37.616327 83.591837-83.591837 83.591837z" fill="#F2CB51" p-id="2316"></path><path d="M694.857143 606.040816H329.142857c-11.493878 0-20.897959-9.404082-20.897959-20.897959s9.404082-20.897959 20.897959-20.897959h365.714286c11.493878 0 20.897959 9.404082 20.897959 20.897959s-9.404082 20.897959-20.897959 20.897959zM694.857143 449.306122H329.142857c-11.493878 0-20.897959-9.404082-20.897959-20.897959s9.404082-20.897959 20.897959-20.897959h365.714286c11.493878 0 20.897959 9.404082 20.897959 20.897959s-9.404082 20.897959-20.897959 20.897959zM701.126531 292.571429h-365.714286c-11.493878 0-20.897959-9.404082-20.897959-20.89796s9.404082-20.897959 20.897959-20.897959h365.714286c11.493878 0 20.897959 9.404082 20.897959 20.897959s-9.404082 20.897959-20.897959 20.89796zM590.367347 762.77551H329.142857c-11.493878 0-20.897959-9.404082-20.897959-20.897959s9.404082-20.897959 20.897959-20.897959h261.22449c11.493878 0 20.897959 9.404082 20.897959 20.897959s-9.404082 20.897959-20.897959 20.897959z" fill="#AF8015" p-id="2317"></path></svg>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-md3">
                <div class="layui-card top-panel">
                    <div class="layui-card-header">图片总数</div>
                    <div class="layui-card-body">
                        <div class="layui-row layui-col-space5">
                            <div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;" id="img_cnt">
                                {{img_cnt}}
                            </div>
                            <div class="layui-col-xs4 layui-col-md4  top-panel-tips">
                                <svg t="1606220413001" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2021" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><defs><style type="text/css"></style></defs><path d="M829.64898 849.502041H194.35102c-43.885714 0-79.412245-35.526531-79.412244-79.412245V253.910204c0-43.885714 35.526531-79.412245 79.412244-79.412245h635.29796c43.885714 0 79.412245 35.526531 79.412244 79.412245v516.179592c0 43.885714-35.526531 79.412245-79.412244 79.412245z" fill="#D2F4FF" p-id="2022"></path><path d="M909.061224 656.195918l-39.706122-48.065306L626.416327 365.714286c-19.330612-19.330612-50.677551-19.330612-70.008164 0L419.526531 502.073469c-2.612245 2.612245-5.22449 3.134694-6.791837 3.134694-1.567347 0-4.702041-0.522449-6.791837-3.134694L368.326531 464.979592c-19.330612-19.330612-50.677551-19.330612-70.008164 0l-143.673469 143.673469-39.706122 48.065306v113.893878c0 43.885714 35.526531 79.412245 79.412244 79.412245h635.29796c43.885714 0 79.412245-35.526531 79.412244-79.412245v-114.416327" fill="#16C4AF" p-id="2023"></path><path d="M273.763265 313.469388m-49.632653 0a49.632653 49.632653 0 1 0 99.265306 0 49.632653 49.632653 0 1 0-99.265306 0Z" fill="#E5404F" p-id="2024"></path><path d="M644.179592 768h-365.714286c-11.493878 0-20.897959-9.404082-20.897959-20.897959s9.404082-20.897959 20.897959-20.897959h365.714286c11.493878 0 20.897959 9.404082 20.897959 20.897959s-9.404082 20.897959-20.897959 20.897959zM461.322449 670.82449h-182.857143c-11.493878 0-20.897959-9.404082-20.897959-20.897959s9.404082-20.897959 20.897959-20.89796h182.857143c11.493878 0 20.897959 9.404082 20.897959 20.89796s-9.404082 20.897959-20.897959 20.897959z" fill="#0B9682" p-id="2025"></path></svg>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-md3">
                <div class="layui-card top-panel">
                    <div class="layui-card-header">附件总数</div>
                    <div class="layui-card-body">
                        <div class="layui-row layui-col-space5">
                            <div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;" id="attachment_cnt">
                                {{attachment_cnt}}
                            </div>
                            <div class="layui-col-xs4 layui-col-md4 top-panel-tips">
                                <svg t="1606220756769" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2461" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><defs><style type="text/css"></style></defs><path d="M805.093878 462.367347H219.428571V194.35102C219.428571 150.465306 254.955102 114.938776 298.840816 114.938776h426.840817c43.885714 0 79.412245 35.526531 79.412245 79.412244v268.016327z" fill="#F2CB51" p-id="2462"></path><path d="M725.681633 909.061224H298.840816c-43.885714 0-79.412245-35.526531-79.412245-79.412244v-109.191837h585.665307v109.191837c0 43.885714-36.04898 79.412245-79.412245 79.412244z" fill="#F2CB51" p-id="2463"></path><path d="M685.97551 257.044898H338.546939c-10.971429 0-19.853061-8.881633-19.853061-19.853061s8.881633-19.853061 19.853061-19.853061h347.428571c10.971429 0 19.853061 8.881633 19.853061 19.853061s-9.404082 19.853061-19.853061 19.853061z" fill="#AF8015" p-id="2464"></path><path d="M829.64898 760.163265H194.35102c-43.885714 0-79.412245-35.526531-79.412244-79.412245V502.073469c0-43.885714 35.526531-79.412245 79.412244-79.412245h635.29796c43.885714 0 79.412245 35.526531 79.412244 79.412245v178.677551c0 43.885714-35.526531 79.412245-79.412244 79.412245z" fill="#E5404F" p-id="2465"></path><path d="M685.97551 359.967347H338.546939c-10.971429 0-19.853061-8.881633-19.853061-19.853061 0-10.971429 8.881633-19.853061 19.853061-19.853062h347.428571c10.971429 0 19.853061 8.881633 19.853061 19.853062 0 10.971429-9.404082 19.853061-19.853061 19.853061z" fill="#AF8015" p-id="2466"></path><path d="M433.632653 619.62449h2.089796l10.971429-4.702041c1.044898-0.522449 2.089796-2.089796 1.567346-3.134694-4.702041-12.016327-10.44898-23.510204-16.195918-33.959184-0.522449-1.044898-2.089796-1.567347-3.657143-1.044898l-9.404081 4.702041c-1.044898 0.522449-2.089796 2.089796-1.044898 3.657143 5.22449 10.44898 9.926531 21.942857 14.628571 33.959184 0 0 0.522449 0.522449 1.044898 0.522449zM377.730612 579.918367c5.22449-14.106122 9.404082-27.689796 13.061225-39.706122v-10.971429c0-1.567347-1.044898-2.612245-2.612245-2.612245H344.816327c-1.567347 0-2.612245 1.044898-2.612245 2.612245v138.971429c0 1.567347 1.044898 2.612245 2.612245 2.612245h10.971428c1.567347 0 2.612245-1.044898 2.612245-2.612245v-24.555102h0.522449c5.746939 0.522449 10.971429 0.522449 15.15102 0 14.106122-2.612245 19.853061-14.106122 16.718368-34.481633-1.567347-8.359184-5.746939-18.285714-13.061225-29.257143z m-19.330612-37.616326h14.106122c-4.179592 14.628571-8.359184 28.212245-12.016326 39.706122-0.522449 1.044898 0 1.567347 0.522449 2.612245 7.314286 9.404082 11.493878 17.763265 13.061224 25.6 2.089796 10.971429 0.522449 17.240816-4.70204 18.285714-3.134694 0.522449-6.791837 0-10.44898-0.522449v-85.681632z" fill="#FFEEF0" p-id="2467"></path><path d="M423.706122 524.016327c-0.522449-0.522449-1.044898-1.044898-1.567346-1.044898l-11.493878-2.612245c-1.567347-0.522449-2.612245 0.522449-3.134694 2.089796-6.791837 22.987755-15.15102 42.840816-26.122449 59.036734-0.522449 1.044898-0.522449 2.089796 0 3.134694 2.089796 3.134694 4.179592 6.791837 5.746939 10.44898 0.522449 1.044898 1.044898 1.567347 2.089796 1.567347s2.089796-0.522449 2.612245-1.044898c2.089796-3.134694 4.179592-6.269388 6.269387-9.926531V668.734694c0 1.567347 1.044898 2.612245 2.612245 2.612245h11.493878c1.567347 0 2.612245-1.044898 2.612245-2.612245v-115.983674c3.134694-7.836735 6.269388-16.718367 9.404081-25.6 0-1.567347 0-2.612245-0.522449-3.134693z" fill="#FFEEF0" p-id="2468"></path><path d="M485.355102 552.228571h-16.195918v-29.257142c0-1.567347-1.044898-2.612245-2.612245-2.612245h-11.493878c-1.567347 0-2.612245 1.044898-2.612245 2.612245v29.257142h-35.004081c-1.567347 0-2.612245 1.044898-2.612245 2.612245v10.971429c0 1.567347 1.044898 2.612245 2.612245 2.612245h35.004081v74.710204c0 5.22449-2.612245 7.836735-8.359183 7.836735-4.702041 0-10.971429-0.522449-18.285715-1.567347-1.044898 0-1.567347 0-2.089796 1.044898s-1.044898 1.567347-0.522449 2.089796c1.044898 4.702041 2.089796 8.881633 2.089796 12.538775 0 1.044898 1.044898 2.089796 2.612245 2.089796 6.269388 0 12.016327 0.522449 17.763266 0.522449 15.673469 0 24.032653-7.836735 24.032653-22.465306v-77.322449H485.877551c1.567347 0 2.612245-1.044898 2.612245-2.612245v-10.971429c-0.522449-1.044898-2.089796-2.089796-3.134694-2.089796zM578.35102 525.583673c-0.522449-0.522449-1.044898-1.044898-1.567347-1.044897l-12.016326-3.657143h-2.089796c-0.522449 0.522449-1.044898 1.044898-1.044898 1.567347-8.359184 28.212245-19.330612 52.767347-32.391837 72.620408-0.522449 0.522449-0.522449 1.567347 0 2.612245 2.089796 4.179592 3.657143 8.359184 5.22449 12.538775 0.522449 1.044898 1.044898 1.567347 2.089796 1.567347s2.089796 0 2.612245-1.044898c4.179592-5.22449 7.836735-10.971429 11.493877-17.240816v74.187755c0 1.567347 1.044898 2.612245 2.612245 2.612245h11.493878c1.567347 0 2.612245-1.044898 2.612245-2.612245v-108.146939c4.179592-9.926531 8.359184-20.897959 11.493877-32.391837 0-0.522449 0-1.044898-0.522449-1.567347z" fill="#FFEEF0" p-id="2469"></path><path d="M679.706122 602.906122h-37.616326v-32.391836h32.914286c1.567347 0 2.612245-1.044898 2.612245-2.612245v-10.44898c0-1.567347-1.044898-2.612245-2.612245-2.612245h-32.914286v-31.869387c0-1.567347-1.044898-2.612245-2.612245-2.612245h-12.016327c-1.567347 0-2.612245 1.044898-2.612244 2.612245v31.869387H606.040816c1.567347-5.746939 3.657143-11.493878 5.22449-17.763265 0.522449-1.567347-0.522449-2.612245-1.567347-3.134694l-12.016326-3.657143c-0.522449 0-1.567347 0-2.089796 0.522449-0.522449 0.522449-1.044898 1.044898-1.044898 1.567347-4.179592 19.853061-11.493878 38.661224-20.37551 54.857143-0.522449 1.044898-0.522449 2.612245 1.044898 3.657143 3.657143 2.612245 6.791837 4.702041 9.404081 7.836735 0.522449 0.522449 1.567347 1.044898 2.089796 0.522449 1.044898 0 1.567347-0.522449 2.089796-1.044898 4.702041-7.836735 8.881633-17.240816 12.538776-27.167347h24.032653v32.391836h-49.110205c-1.567347 0-2.612245 1.044898-2.612244 2.612245v10.44898c0 1.567347 1.044898 2.612245 2.612244 2.612245h49.110205v49.110204c0 1.567347 1.044898 2.612245 2.612244 2.612245h12.016327c1.567347 0 2.612245-1.044898 2.612245-2.612245v-49.110204h37.616326c1.567347 0 2.612245-1.044898 2.612245-2.612245v-10.44898c-0.522449-2.089796-2.089796-3.134694-3.134694-3.134694z" fill="#FFEEF0" p-id="2470"></path></svg>                        
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    
        </div>
        <!-- 觅思文档版本信息 -->
        <div class="layui-col-xs6 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">MrDoc {{mrdoc_version}}</div>
                <div class="layui-card-body">
                    <div style="margin-bottom: 5px;">
                        <a href="https://doc.mrdoc.pro/project-7/doc-3441/" class="pear-btn layui-btn-fluid" target="_blank">
                            <i class="layui-icon layui-icon-rate-solid" style="color:rgb(242, 203, 81);"></i>
                            <span style="font-weight:700;color:red;">升级专业版享折扣！</span>
                        </a>
                    </div>
                    <div style="margin-bottom: 5px;">
                        <a href="https://gitee.com/zmister/MrDoc" class="pear-btn layui-btn-fluid" target="_blank">访问 Gitee</a>
                    </div>
                    <div style="margin-bottom: 5px;">
                        <a href="https://github.com/zmister2016/MrDoc" class="pear-btn layui-btn-fluid" target="_blank">访问 GitHub</a>
                    </div>
                    <div style="margin-bottom: 5px;">
                        <a href="http://shang.qq.com/wpa/qunwpa?idkey=143c23a4ffbd0ba9137d2bce3ee86c83532c05259a0542a69527e36615e64dba" class="pear-btn layui-btn-fluid" target="_blank">加入 QQ群</a>
                    </div>
                    <div style="margin-bottom: 5px;">
                        <button class="pear-btn layui-btn-fluid" onclick="checkUpdate()">检查版本更新</button>
                    </div>

                </div>
              </div>
        </div>
    </div>
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">动态</div>
                <div class="layui-card-body">
                    <dl class="layuiadmin-card-status">
                        {% for doc in doc_active_list %}
                        <dd>
                            <div class="layui-status-img"><a href="javascript:;"><img style="width: 32px;height: 32px;border-radius: 50px;"
                                        src="{% static 'PearAdminLayui/avatar.svg' %}"></a></div>
                            <div>
                                {% if doc.status == 1 %}
                                <p>{{doc.create_user.first_name}} 发布了文档 <a href="{% url 'doc' doc.top_doc doc.id %}" target="_blank">{{doc.name}}</a></p>
                                {% elif doc.status == 0 %}
                                <p>{{doc.create_user.first_name}} 保存了文档 <a href="{% url 'modify_doc' doc.id %}" target="_blank">{{doc.name}}</a></p>
                                {% else %}
                                <p>{{doc.create_user.first_name}} 删除了文档 <a>{{doc.name}}</a></p>
                                {% endif %}
                                <span>{{doc.modify_time}}</span>
                            </div>
                        </dd>
                        {% endfor %}
                    </dl>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">快速草稿</div>
                <div class="layui-card-body">
                    <div class="layui-form">
                        {% csrf_token %}
                        <input name="status" value="0" hidden>
                        <div class="layui-form-item">
                            <label class="layui-form-label">标题</label>
                            <div class="layui-input-block">
                            <input type="text" id="doc_name" name="doc_name" required  lay-verify="required" placeholder="请输入文档标题" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">文集</label>
                            <div class="layui-input-block">
                            <select name="project" id="project" lay-verify="required">
                                <option value=""></option>
                                {% for pro in pro_list %}
                                    {% if pro.role == 0 %}
                                    <option value="{{pro.id}}">[公开]{{pro.name}}</option>
                                    {% elif pro.role == 1 %}
                                    <option value="{{pro.id}}">[私密]{{pro.name}}</option>
                                    {% elif pro.role == 2 %}
                                    <option value="{{pro.id}}">[指定用户]{{pro.name}}</option>
                                    {% elif pro.role == 3 %}
                                    <option value="{{pro.id}}">[密码]{{pro.name}}</option>
                                    {% endif %}
                                {% endfor %}
                            </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">文本域</label>
                            <div class="layui-input-block">
                            <textarea name="pre_content" id="pre_content" placeholder="在想些什么呢？" class="layui-textarea"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                            <button class="pear-btn pear-btn-primary" id="save_doc" onclick="manage_overview_save_doc();">保存草稿</button>
                            <button type="reset" class="pear-btn pear-btn-primary">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-header">捐赠 - 请作者喝杯奶茶吧</div>
                <div class="layui-card-body">
                    <p align="center">
                        <img src="{% static 'dashang/dashang_wx.webp' %}" height=200>
                        <img src="{% static 'dashang/dashang_alipay.webp' %}" height=200>
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>
<!--</div>-->
{% endblock %}

{% block custom_script %}
    <script>
        layui.use(['layer', 'echarts', 'element', 'count','topBar','form'], function() {
            var $ = layui.jquery,
                layer = layui.layer,
                form = layui.form,
                element = layui.element,
                count = layui.count,
                echarts = layui.echarts;
            $.ajaxSetup({
                data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
            });
            // 保存文档草稿
            manage_overview_save_doc = function(){
                $('button.pear-btn').attr("disabled",true);
                $('button.pear-btn').addClass('pear-btn-disabled');
                var data = {
                    'project':$("#project").val(),
                    'doc_name':$("#doc_name").val(),
                    'pre_content':$("#pre_content").val(),
                    'status':0
                }
                console.log(data)
                if(data.doc_name == ""){
                    layer.msg('请输入文档标题！');
                    $('button.pear-btn').attr("disabled",false);
                    $('button.pear-btn').removeClass('pear-btn-disabled');
                }
                else if(data.project == ""){
                    layer.msg('请选择文集！');
                    $('button.pear-btn').attr("disabled",false);
                    $('button.pear-btn').removeClass('pear-btn-disabled');
                }
                else{
                    layer.load(1);
                    $.post("{% url 'create_doc' %}",data,function(r){
                        if(r.status){
                            //保存成功
                            layer.closeAll("loading");
                            md_changed = false;
                            layer.msg('保存草稿成功',function(){
                                window.location.reload()
                            });
                        }else{
                            //创建失败
                            layer.closeAll("loading");
                            layer.msg('保存草稿失败:'+r.data);
                            $('button.pear-btn').attr("disabled",false);
                            $('button.pear-btn').removeClass('pear-btn-disabled');
                        }
                    });
                }
            };
        });
    </script>
{% endblock %}
